import datetime
import tushare as ts


class StockDataQuery:
    def get_daily_data(self, stock_code):

        # 获取股票日线行情
        ts.set_token("9178f4653b48b9f2b86e50aedec71960f76540cd96effe1ed9360dea")
        self.pro = ts.pro_api()
        today = datetime.today()
        start_date = today.strftime("%Y%m%d")
        end_date = (today - datetime.timedelta(days=180)).strftime("%Y%m%d")
        df = self.pro.daily(
            ts_code=stock_code, start_date=start_date, end_date=end_date
        )

        # 返回数据
        return df


# 使用示例
if __name__ == "__main__":
    stock_query = StockDataQuery()
    daily_data = stock_query.get_daily_data("600519.SH")
    AntLogger.infodaily_data)
